package com.tuojiahr.service.impl;

import java.util.List;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.tuojiahr.common.HibernatePageCommon;
import com.tuojiahr.domain.TuoJiaHrColumn;
import com.tuojiahr.domain.TuoJiaHrOrdinaryColumn;
import com.tuojiahr.service.ColumnService;

/**
 * 说明：
 *
 * @author wang.haibo
 * @date 2012-11-11 下午8:59:24
 */

@Transactional
public class ColumnServiceImpl extends HibernatePageCommon implements
		ColumnService {

	//获得首页导航
	@SuppressWarnings("unchecked")
	@Override
	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public List<TuoJiaHrColumn> getColoumns() {
		return getSession().createQuery("from TuoJiaHrColumn c order by c.orderNum").list();
	}

	//获得在首页显示的普通栏目
	@SuppressWarnings("unchecked")
	@Override
	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public List<TuoJiaHrOrdinaryColumn> getOrdinaryColumnIsHomeShow() {
		return getSession().createQuery("from TuoJiaHrOrdinaryColumn oc where oc.homeShow = 'y' order by oc.orderNum").list();
	}

	// 根据id加载
	@Override
	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public TuoJiaHrColumn getColumnById(long id) {
		return getHibernateTemplate().load(TuoJiaHrColumn.class, id);
	}
}
